package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.ChannelDTO;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理", tags = "敏感词管理")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService sensitiveService;

    @PostMapping("list")
    @ApiOperation("敏感词分页列表查询")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDTO dto) {
        return sensitiveService.findByNameAndPage(dto);
    }

    @PostMapping("save")
    @ApiOperation("添加敏感词")
    public ResponseResult insert(@RequestBody AdSensitive sensitive) {
        return sensitiveService.insert(sensitive);
    }

    @PostMapping("update")
    @ApiOperation("修改敏感词")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return sensitiveService.update(adSensitive);
    }

    @DeleteMapping ("del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return sensitiveService.delete(id);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return sensitiveService.selectAllSensitives();
    }
}
